package top.chendawei.util;

import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;

@Slf4j
public class DateUtils {
    public static final long SECOND = 1000L;
    public static final long MINUTE = 60000L;
    public static final long HOUR = 3600000L;
    public static final long DAY = 86400000L;
    public static final long WEEK = 604800000L;
    public static final long MONTH = 2592000000L;
    public static final long YEAR = 31536000000L;
    public static final String DATE_FORMAT = "yyyy-MM-dd";

    public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static String getDateString(java.util.Date date, String formatPattern) {
        if (date == null) {
            return "";
        }
        if (null == formatPattern) {
            formatPattern = DATE_TIME_FORMAT;
        }
        return (new DateTime(date)).toString(formatPattern);
    }


    public static String getCurrDate(String formatPattern) {
        if (null == formatPattern) {
            formatPattern = DATE_TIME_FORMAT;
        }
        return DateTime.now().toString(formatPattern);
    }

}
